package org.jeecg.modules.health_records.health_auxi.service.impl;

import org.jeecg.modules.health_records.health_auxi.entity.HealthAuxiExamInfo;
import org.jeecg.modules.health_records.health_auxi.mapper.HealthAuxiExamInfoMapper;
import org.jeecg.modules.health_records.health_auxi.service.IHealthAuxiExamInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 各项辅助检查信息表
 * @Author: jeecg-boot
 * @Date:   2025-07-02
 * @Version: V1.0
 */
@Service
public class HealthAuxiExamInfoServiceImpl extends ServiceImpl<HealthAuxiExamInfoMapper, HealthAuxiExamInfo> implements IHealthAuxiExamInfoService {

    @Autowired
    private HealthAuxiExamInfoMapper healthAuxiExamInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAuxiExamInfo> queryByRecordId(HealthAuxiExamInfo healthAuxiExamInfo) {
        return healthAuxiExamInfoMapper.queryByRecordId(Long.valueOf(healthAuxiExamInfo.getRecordid()), healthAuxiExamInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAuxiExamInfo> queryElecRecord(HealthAuxiExamInfo healthAuxiExamInfo) {
        return healthAuxiExamInfoMapper.queryElecRecord(Long.valueOf(healthAuxiExamInfo.getRecordid()), healthAuxiExamInfo.getIdNumber());

    }

    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAuxiExamInfo> newQueryElecRecord(HealthAuxiExamInfo healthAuxiExamInfo) {
        return healthAuxiExamInfoMapper.newQueryElecRecord(Long.valueOf(healthAuxiExamInfo.getRecordid()),healthAuxiExamInfo.getSeeId(),healthAuxiExamInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAuxiExamInfo> newQueryPastRecord(HealthAuxiExamInfo healthAuxiExamInfo) {
        return healthAuxiExamInfoMapper.newQueryPastRecord(Long.valueOf(healthAuxiExamInfo.getRecordid()),healthAuxiExamInfo.getSeeId(),healthAuxiExamInfo.getIdNumber());

    }
}
